<div class="content_filtro">
    <div class="filtro">
        <form id="form_filtro" method="get" action="">
            <i>Filtrar</i>
            <label><?php echo elemform::radio('stfiltro','stfiltro','1',$this->stfiltro); ?> Ativo</label>
            <label><?php echo elemform::radio('stfiltro','stfiltro','0',$this->stfiltro); ?> Inativo</label>
            
            <input type="text" id="filtro_an" name="filtro_an" placeholder="Ano" value="<?php echo $this->filtro_an?>" maxlength="4" style="width: 35px !important;" />
            
            <?php
               
                $query = 'SELECT SQL_CACHE CUR_ID FROM CURSO ORDER BY CUR_ANO DESC';
                $f_cur = $this->db->fetchAll($query);

                $html = '<select id="filtro_tr" name="filtro_tr">';
                $html .= '<option value="">Turma</option>';
                foreach($f_cur as $r){   
                    $select = $this->filtro_tr == $r['CUR_ID'] ? 'selected':''; 
                    $html .= '<option '.$select.' value="'.$r['CUR_ID'].'">'.dominio::getTurma($r['CUR_ID'],0).'</option>'; // $r['CUR_NOM'] 
                }
                $html .= '</select>';
                echo $html;
               
            ?>
           
            <input type="text" name="filtro_nm" placeholder="Aluno" value="<?php echo $this->filtro_nm?>" />
            
            <input type="submit" class="btn-pdr" name="buscar" value="buscar" />
            
        </form>
    </div>
    
    <?php if($this->per_add){?>
    <div class="content-btn">
        <span>Novo</span><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit','id'=>'')); ?>">+</a>
    </div>
    <?php } ?>
    
</div>

<div class="content-list">
    
    <h2><?php echo $this->titulo;?></h2>
    <br>
    
    <ul class="list-alunos">
    <?php foreach ($this->result as $row) { 

        $img = ''; 
        $imgs = 'public/upload/aluno/'.$row['ALU_ID'].'_tmb.*';
        foreach (glob($imgs) as $src) {
            $img = $src;
        }
        if(strlen($img) < 5){
            $img = 'public/media/images/aluno.png'; 
        }
        
        $cancelar = true;
        $query = 'SELECT SQL_CACHE PAR_NUM FROM PARCELAMENTO WHERE MAT_ID = '.$row['MAT_ID'].' and PAR_STAPGO in(0,1)';
        $pars = $this->db->fetchRow($query);
        if($pars['PAR_NUM'] > 0) $cancelar = false;
        
    ?> 
        <li>
            <div class="content-foto"><img src="<?php echo '/'.$img; ?>" /></div>
            <div class="row"><strong><?php echo $row['ALU_NOM'].' - '.$row['ALU_ID']; ?></strong></div>
            <div class="row"><?php echo Datetools::invertDH_D($row['MAT_DATHOR']); ?> - <?php echo $row['MAT_ID'];?></div>
            <div class="row rwu"><?php echo dominio::getTurma($row['CUR_ID'],0); ?></div>
            <div class="content-btn">
                <?php /* if($this->per_edt){?><a class="btn-bar-list" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'boleto', 'id' => $row['CUR_ID'])); ?>" target="_blank">Boleto</a><?php } */ ?>
                <?php if($this->per_edt){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $row['MAT_ID'])); ?>">Editar</a><?php }?>
                <?php if($this->per_del && $cancelar == true){?><a class="btn-pdr" href="javascript:void(0);" onclick="url_delete_msg('<?php echo $this->controller; ?>', <?php echo $row['MAT_ID'] ?>, $(this), '<?php echo $row['ALU_NOM']; ?>');">Cancelar</a><?php } ?>
                <?php if($this->per_edt){?><a class="btn-pdr" target="_blank" href="<?php echo $this->url(array('controller' => 'aluno', 'action' => 'edit', 'id' => $row['ALU_ID'])); ?>">Cadastro</a><?php }?>
                <?php if($this->per_edt && $cancelar == false){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => 'parcelamento', 'action' => 'index', 'mat_id' => $row['MAT_ID'])); ?>">Pagamento</a><?php }?>
            </div>
        </li>
    <?php  } ?>
    </ul>
    
    <?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>
</div>